package cn.javabb.controller;

import cn.javabb.common.entity.Student;
import cn.javabb.service.StudentService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @desc:
 * @author: javabb (javabob(a)163.com)
 * @create: 2020/05/28 20:18
 */
@RestController
@RequestMapping("/student")
public class StudentProviderController {
    @Autowired
    private StudentService studentService;

    @GetMapping("/all")
    public Object queryAll() {
        System.out.println("queryAll:-----------1005------------");
        return studentService.queryAll();
    }

    @PostMapping("/save")
    public Object save(@RequestBody Student student) {
        return studentService.save(student);
    }

    @GetMapping("/query/{id}")
    public Object queryone(@PathVariable("id") Integer id) {
        return studentService.queryOne(id);
    }

    @GetMapping("/delete/{id}")
    public Object delete(@PathVariable("id") Integer id) {
        return studentService.deleteById(id);
    }

    /**
     * 获取信息
     * @return
     * @throws InterruptedException
     */
    @ResponseBody
    @GetMapping("/getInfo")
    public Map<String,Object> getInfo() throws InterruptedException {
        //Thread.sleep(1000);
        return studentService.getInfo();
    }


}
